<template>
  <div class="container-fluid row" style="height: 100%">
    <div
      class="col-lg-3 col-md-5 col-sm-6 position-absolute top-50 start-50 translate-middle"
    >
      <h4 class="text-center" style="line-height: 60px">
        <img
          alt="LumbaShark"
          height="80"
          src="../../assets/Logo.png"
          width="80"
        />
      </h4>
      <div class="card text-white bg-success mb-3">
        <div class="card-body">
          <div class="text-center">
            <h6>{{ $t("oauth.callback.title") }}</h6>
            <span>{{ $t("oauth.callback.descriptions.0") }}</span>
            <br />
            <span>
              <b>{{ $t("oauth.callback.descriptions.1") }}</b
              >{{ $t("oauth.callback.descriptions.2") }}</span
            >
          </div>
        </div>
        <hr />
        <div class="card-body">
          <div class="alert alert-light">
            <span>
              <n-tooltip trigger="hover">
                <template #trigger>
                  <code
                    style="cursor: copy"
                    v-clipboard:copy="route.query['code']"
                    v-clipboard:success="copySuccess"
                    v-clipboard:error="copyError"
                    ><b>{{ route.query["code"] }}</b></code
                  >
                </template>
                {{ $t("oauth.callback.copy") }}
              </n-tooltip>
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { NTooltip, useMessage } from "naive-ui";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";

const { t } = useI18n();
const route = useRoute();
const message = useMessage();

function copyError() {
  message.error(t("common.message.copy-failed"));
  console.log(error);
}

function copySuccess() {
  message.success(t("common.messages.copy-success"));
}
</script>
